import Services from './services';
console.log('process.env.PUBLIC_API', process.env.PUBLIC_API);
const apiUrl =
  process && process.env && process.env.NODE_ENV === 'development'
    ? '/api/asterism/v1'
    : `${process.env.REACT_APP_API}api/asterism/v1`;
const apiUrlNoVersion =
  process && process.env && process.env.NODE_ENV === 'development'
    ? '/api/asterism'
    : `${process.env.REACT_APP_API}api/asterism`;
export const apiUrlStd =
  process && process.env && process.env.NODE_ENV === 'development' ? '/auth' : `${process.env.REACT_APP_API}auth`;

export const apiUrlDataGateway =
  process && process.env && process.env.NODE_ENV === 'development'
    ? '/api/dataGateway'
    : `${process.env.REACT_APP_API}api/dataGateway`;

export const apiUrlDataGatewayFee =
  process && process.env && process.env.NODE_ENV === 'development'
    ? '/api/dataGatewayFee'
    : `${process.env.REACT_APP_API}api/dataGatewayFee`;

export const APIUrl = apiUrl;
export const APIUrlNoVersion = apiUrlNoVersion;

const portalApiUrl =
  process && process.env && process.env.NODE_ENV === 'development'
    ? '/dev-api'
    : `${process.env.REACT_APP_API}api/portal/std`;
const smpApiUrl =
  process && process.env && process.env.NODE_ENV === 'development' ? '/api/smp' : `${process.env.REACT_APP_API}api/smp`;

const services = new Services(apiUrl, true);
export const servicesNoVersion = new Services(apiUrlNoVersion, true);
export const servicesDataGateway = new Services(apiUrlDataGateway, true);
export const servicesDataGatewayFee = new Services(apiUrlDataGatewayFee, true);

export const servicesPortal = new Services(portalApiUrl, true);
export const servicesSmp = new Services(smpApiUrl, true);

/** 这是把整个站点用到的services实例对象以一个数组形式export出去，
 *  以后每新增一个service实例，请将该实例加入这个数组，/src/model/servicesMiddleWare.js 中需要引用这个数组
 *  方便给每一个接口，加request header ：{modules:['菜单模块1','菜单模块1']}
 * */
export const servicesGroup = [
  services,
  servicesNoVersion,
  servicesDataGateway,
  servicesDataGatewayFee,
  servicesPortal,
  servicesSmp,
];

export default services;
